<template>
  <div>
    <van-cell-group border>
  <van-field v-model="password" label="密码" placeholder="请输入密码.." autofocus/>
</van-cell-group>
<div class="loginBtn">
<van-button type="danger" round block :disabled="flag" @click="register">完成</van-button>

</div>
  </div>
</template>

<script>
import { doRegister } from "../../api/user";
import Vue from 'vue';
import {  CellGroup,Button} from 'vant';

Vue.use(CellGroup);
Vue.use(Button);
export default {
data () {
    return {
        password:'',
       
    }
},
methods: {
    register(){
        doRegister({tel:localStorage.getItem("tel"),password:this.password}).then(()=>{
            localStorage.setItem("password",this.password)
            this.$router.push("/login")
        })
    }
},
computed: {
    flag(){
        //满足输入的内容满足密码的正则规则
        if(/^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])\S*$/.test(this.password)){
            return false;
        }else{
            return true
        }
    }
},

}
</script>

<style scoped>
.loginBtn{
    width: 80%;
    margin: 20px auto;
}
</style>